#!/bin/sh
#
# Installation script for Suse Linux
# 

echo -n "SiI 3132 Driver Installation."
a="i386-sles9"
if [ ! -f linux/suse/i386-sles9/install/update.tar.gz ] ; then
   a="x86_64-sles9"
   if [ ! -f linux/suse/x86_64-sles9/install/update.tar.gz ] ; then
      echo "failed"
      echo "Missing Silicon Image Driver Disk for SuSE Linux"
      exit 1
   fi
fi
echo -n "."

rm -rf /tmp/.sii
mkdir -p /tmp/.sii
echo -n "."

cp linux/suse/$a/install/update.tar.gz /tmp/.sii

if [ $? -ne 0 ] ; then
   echo "Failed to copy driver"
   echo "Exit......"
   exit 1
fi

cd /
echo -n "."

tar xzf /tmp/.sii/update.tar.gz >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo "Failed to extract driver files.)"
   exit 1
fi
cd lib/modules
echo -n "."

for i in `ls -d 2.6.5-7.191-*`
do
if [ "x" != "x" ];then
      ko="/lib/modules/${i}/kernel/drivers/scsi/"
      if [ -e ${ko} ]; then
          rm -f ${ko};  
      fi
fi
      depmod ${i} >/dev/null 2>&1
      echo -n "."
done

if ! lsmod | grep si3132r5 >/dev/null 2>&1 ; then
   insmod /lib/modules/`uname -r`/kernel/drivers/scsi/si3132r5.ko >/dev/null 2>&1  
fi
echo -n "."

sed -e '/INITRD_MODULES/s/"/ si3132r5"/2' /etc/sysconfig/kernel > /tmp/.kernel.tmp
mv -f /tmp/.kernel.tmp /etc/sysconfig/kernel

/sbin/mkinitrd -k "vmlinuz-"`uname -r` -i "initrd-"`uname -r` >/dev/null 2>&1

echo "setup is done."
